{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Grove Temperature sensor module\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Aim\n",
    "\n",
    "* This notebook illustrates how to use available APIs for the Grove Temperature sensor module on PYNQ-Z2 PMOD and Arduino interfaces.\n",
    "\n",
    "## References\n",
    "* [Grove Temperature sensor](https://www.seeedstudio.com/Grove-Temperature-Sensor.html) \n",
    "* [Grove I2C ADC](https://www.seeedstudio.com/Grove-I2C-ADC.html) \n",
    "* [PYNQ Grove Adapter](https://store.digilentinc.com/pynq-grove-system-add-on-board/)   \n",
    "* [Grove Base Shield V2.0](https://www.seeedstudio.com/Base-Shield-V2.html)   \n",
    "\n",
    "## Last revised\n",
    "* 01 April 2021\n",
    "    + Initial version\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Load _base_ Overlay"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<div class=\"alert alert-box alert-info\">\n",
    "Note that we load the base bitstream only once to use Grove module with PYNQ Grove Adapter and SEEED Grove Base Shield V2.0<br>\n",
    "Please make sure you run the following cell before running either of the interfaces \n",
    "</div>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/javascript": [
       "\n",
       "try {\n",
       "require(['notebook/js/codecell'], function(codecell) {\n",
       "  codecell.CodeCell.options_default.highlight_modes[\n",
       "      'magic_text/x-csrc'] = {'reg':[/^%%microblaze/]};\n",
       "  Jupyter.notebook.events.one('kernel_ready.Kernel', function(){\n",
       "      Jupyter.notebook.get_cells().map(function(cell){\n",
       "          if (cell.cell_type == 'code'){ cell.auto_highlight(); } }) ;\n",
       "  });\n",
       "});\n",
       "} catch (e) {};\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "try {\n",
       "require(['notebook/js/codecell'], function(codecell) {\n",
       "  codecell.CodeCell.options_default.highlight_modes[\n",
       "      'magic_text/x-csrc'] = {'reg':[/^%%pybind11/]};\n",
       "  Jupyter.notebook.events.one('kernel_ready.Kernel', function(){\n",
       "      Jupyter.notebook.get_cells().map(function(cell){\n",
       "          if (cell.cell_type == 'code'){ cell.auto_highlight(); } }) ;\n",
       "  });\n",
       "});\n",
       "} catch (e) {};\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from pynq.overlays.base import BaseOverlay\n",
    "from pynq_peripherals import ArduinoSEEEDGroveAdapter, PmodGroveAdapter\n",
    "base = BaseOverlay('base.bit')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Using Grove Temperature sensor with Grove Base Shield V2.0 (Arduino)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<div class=\"alert alert-box alert-warning\"><ul>\n",
    "    <h4 class=\"alert-heading\">Make Physical Connections </h4>\n",
    "    <li>Insert the Grove Base Shield into the Arduino connector on the board. Connect the Grove Temperature sensor module to A1 connector of the SEEED Grove Base Shield.</li>\n",
    "</ul>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Adapter configuration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "adapter = ArduinoSEEEDGroveAdapter(base.ARDUINO, A1='grove_temperature')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Define device object"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "temp_sensor = adapter.A1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Reading from the Grove Temperature sensor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "temperature: 30.10\n"
     ]
    }
   ],
   "source": [
    "print('temperature: {:.2f}'.format(temp_sensor.get_temperature()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Taking multiple samples at a desired interval and plotting\n",
    "Set numberOfSamples and delayInSeconds to desired values. Print samples and then plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "temperature: 29.84\n",
      "temperature: 30.27\n",
      "temperature: 31.38\n",
      "temperature: 32.04\n",
      "temperature: 32.41\n",
      "temperature: 32.54\n",
      "temperature: 32.64\n",
      "temperature: 32.92\n",
      "temperature: 33.16\n",
      "temperature: 33.16\n",
      "temperature: 33.12\n",
      "temperature: 33.12\n",
      "temperature: 33.22\n",
      "temperature: 33.23\n",
      "temperature: 33.24\n",
      "temperature: 33.22\n",
      "temperature: 33.02\n",
      "temperature: 32.83\n",
      "temperature: 32.66\n",
      "temperature: 32.44\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEICAYAAABcVE8dAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAF6FJREFUeJzt3X2QJHd93/H35x6QdEiWgFuDxKE7YwIUT3pgIwswYATCZ9kBEsCGXAwGk0NFcEJwglU5BxtSV8VDGQeIjXM8GBEWEObBEAU5iESEZ0krfDqQEeZE6QRCSAvmQOIooYdv/uheM7fah7nbmdnZ7ferampmfv30nb6+z/b8uqc7VYUkae1bt9IFSJJGw8CXpI4w8CWpIwx8SeoIA1+SOsLAl6SOMPAlqSMMfC0pyfOSXJ7kx0luaV+/LElWsKZTk9zW86i2vtn3T1yp2pYrybHt59my0rVobTHwtagkvw+8GXgj8ADg/sD5wBOAey0wzfph11VVN1T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r4EPH4F6nxwu/yr21pm12dvnQH+rF3fXwEmV6DOe9ME+Ik9bSu+Lmn+AN0E3EHTz/m7NMeL/g/wDeBTwH3bcSeBd/RM++J2G90PvGgF6txP0087u33Ontl2CvCJxbaPEdf5P9rtbh9NWJ08t872/T1yYZR1tu3vnt0me8ZdkfW5SAYNbfv00gqS1BGdP2grSV1h4EtSRxj4ktQRBr4kdYSBL0kdYeBLUkcY+JLUEf8ftcGPKBsu6ZUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xac73e9b0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "from time import sleep\n",
    "import numpy as np\n",
    "\n",
    "numberOfSamples = 20\n",
    "delayInSeconds = 1\n",
    "temperature = np.zeros(numberOfSamples)\n",
    "\n",
    "for i in range(numberOfSamples):\n",
    "    temperature[i]=temp_sensor.get_temperature()\n",
    "    sleep(delayInSeconds)\n",
    "\n",
    "for i in range(20):\n",
    "    print('temperature: {:.2f}'.format(temperature[i]))\n",
    "    \n",
    "plt.plot(range(numberOfSamples), temperature, 'ro')\n",
    "plt.title('Grove Temperature')\n",
    "plt.axis([0, int(len(temperature)), min(temperature)-1, max(temperature)+1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "## Using Grove Temperature sensor with Grove ADC (Arduino)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<div class=\"alert alert-box alert-warning\"><ul>\n",
    "    <h4 class=\"alert-heading\">Make Physical Connections </h4>\n",
    "    <li>Insert the SEEED Grove Base Shield into the Arduino connector on the board. Connect the grove_adc module to one of the connectors labeled I2C.</li>\n",
    "    <li>Connect the Grove Temperature sensor module to the grove_adc module.</li></ul>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Adapter configuration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "adapter=ArduinoSEEEDGroveAdapter(base.ARDUINO, I2C='grove_temperature')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Define device object"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "temp_sensor = adapter.I2C"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Reading from the Grove Temperature sensor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print('temperature: {:.2f}'.format(temp_sensor.get_temperature()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Taking multiple samples at a desired interval and plotting\n",
    "Set numberOfSamples and delayInSeconds to desired values. Print samples and then plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "from time import sleep\n",
    "import numpy as np\n",
    "\n",
    "numberOfSamples = 20\n",
    "delayInSeconds = 1\n",
    "temperature = np.zeros(numberOfSamples)\n",
    "\n",
    "for i in range(numberOfSamples):\n",
    "    temperature[i]=temp_sensor.get_temperature()\n",
    "    sleep(delayInSeconds)\n",
    "\n",
    "for i in range(20):\n",
    "    print('temperature: {:.2f}'.format(temperature[i]))\n",
    "    \n",
    "plt.plot(range(numberOfSamples), temperature, 'ro')\n",
    "plt.title('Grove Temperature')\n",
    "plt.axis([0, int(len(temperature)), min(temperature)-1, max(temperature)+1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "## Using Grove Temperature sensor with PYNQ Grove Adapter (PMOD)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<div class=\"alert alert-box alert-warning\"><ul>\n",
    "    <h4 class=\"alert-heading\">Make Physical Connections </h4>\n",
    "    <li>Connect the PYNQ Grove Adapter to PMODB connector.  Connect the grove_adc module to the G3 connector of the Adapter.</li>\n",
    "    <li>Connect the Grove Temperature sensor module to the grove_adc module.</li></ul>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Adapter configuration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "adapter = PmodGroveAdapter(base.PMODB, G3='grove_temperature')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Define device object"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "temp_sensor = adapter.G3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Reading from the Grove Temperature sensor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "ename": "MicroblazeError",
     "evalue": "An Unknown Error Occurred",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mMicroblazeError\u001b[0m                           Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-15-0907eb37fefb>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'temperature: {:.2f}'\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtemp_sensor\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_temperature\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;32m<string>\u001b[0m in \u001b[0;36mwrapped\u001b[0;34m(self)\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/pynq/lib/pynqmicroblaze/rpc.py\u001b[0m in \u001b[0;36m_call_func\u001b[0;34m(self, function, *args)\u001b[0m\n\u001b[1;32m    800\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    801\u001b[0m             \u001b[0;32mdef\u001b[0m \u001b[0m_call_func\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfunction\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 802\u001b[0;31m                 \u001b[0;32mreturn\u001b[0m \u001b[0mfunction\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_val\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    803\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    804\u001b[0m             \u001b[0;32mdef\u001b[0m \u001b[0m__repr__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m<string>\u001b[0m in \u001b[0;36mcall\u001b[0;34m(self, temp)\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/pynq/lib/pynqmicroblaze/rpc.py\u001b[0m in \u001b[0;36mcall\u001b[0;34m(self, *args)\u001b[0m\n\u001b[1;32m    891\u001b[0m         \u001b[0mdone\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    892\u001b[0m         \u001b[0;32mwhile\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mdone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 893\u001b[0;31m             \u001b[0mreturn_value\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdone\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_handle_stream\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    894\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    895\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreturn_type\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/pynq/lib/pynqmicroblaze/rpc.py\u001b[0m in \u001b[0;36m_handle_stream\u001b[0;34m(self, *args)\u001b[0m\n\u001b[1;32m    879\u001b[0m             \u001b[0m_handle_command\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcommand\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstream\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    880\u001b[0m             \u001b[0;32mreturn\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 881\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfunction\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreceive_response\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstream\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    882\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    883\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0m__repr__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/pynq/lib/pynqmicroblaze/rpc.py\u001b[0m in \u001b[0;36mreceive_response\u001b[0;34m(self, stream, *args)\u001b[0m\n\u001b[1;32m    561\u001b[0m              \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marg_interfaces\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    562\u001b[0m         )]\n\u001b[0;32m--> 563\u001b[0;31m         \u001b[0mreturn_value\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreturn_interface\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreturn_decode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstream\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    564\u001b[0m         \u001b[0;32mreturn\u001b[0m \u001b[0mreturn_value\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    565\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/pynq/lib/pynqmicroblaze/rpc.py\u001b[0m in \u001b[0;36mreturn_decode\u001b[0;34m(self, stream)\u001b[0m\n\u001b[1;32m    361\u001b[0m         \u001b[0mval\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_struct\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0munpack\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    362\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mmath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0misnan\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mval\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 363\u001b[0;31m             \u001b[0;32mraise\u001b[0m \u001b[0mMicroblazeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"An Unknown Error Occurred\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    364\u001b[0m         \u001b[0;32mreturn\u001b[0m \u001b[0mval\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    365\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mMicroblazeError\u001b[0m: An Unknown Error Occurred"
     ]
    }
   ],
   "source": [
    "print('temperature: {:.2f}'.format(temp_sensor.get_temperature()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Taking multiple samples at a desired interval and plotting\n",
    "Set numberOfSamples and delayInSeconds to desired values. Print samples and then plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "temperature: 33.51\n",
      "temperature: 33.73\n",
      "temperature: 34.14\n",
      "temperature: 34.72\n",
      "temperature: 35.18\n",
      "temperature: 35.23\n",
      "temperature: 35.37\n",
      "temperature: 35.74\n",
      "temperature: 35.69\n",
      "temperature: 35.46\n",
      "temperature: 35.14\n",
      "temperature: 34.95\n",
      "temperature: 34.68\n",
      "temperature: 34.50\n",
      "temperature: 34.32\n",
      "temperature: 34.23\n",
      "temperature: 34.00\n",
      "temperature: 33.86\n",
      "temperature: 33.69\n",
      "temperature: 33.55\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEICAYAAACwDehOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAHR5JREFUeJzt3X20XXV95/H3J5eYhAchNFcJBHJ5UgQKAU9THyoUFEiZDjCDVjQdqQ6TRoUWnRmKwwwt2KxFdbW2MhYNlQdngpAiYBYl1TBGK7UknGgChMcEEyACuRIjRGgKyXf+2L+7ORzOuXffe/d5uPd+XmuddffTb5/vPjnZ3/Pbv9/+bUUEZmZmAJM6HYCZmXUPJwUzM8s5KZiZWc5JwczMck4KZmaWc1IwM7Ock4KZmeWcFKw0ks6TtErSryRtTdOfkqQOxnSIpB01r0jxDcy/r1OxjZakqel4ZnU6Fhs/nBSsFJL+K/A3wBeBA4C3AguB9wJvalKmp9VxRcSTEbH3wCstPr5m2Q9bHcNISdqjDe/R8n8DG1ucFGzUJO0LXAl8KiJujYgXI/OTiJgfETvTdjdIukbSXZJ+BZwiaV9J35DUL2mzpP8paZKkKZK2Szq25n16Jb0s6S1p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8hqhI0M9R1phwvTZa7rmlzu6JbP833AcxHxeJP1Hfks685DLfl+uqG5AEl7A98CLo6IF+pW/5jsEsjxwNXAG8Z2apPfiogTgd8BPi3ppA7FMSRJbwLOAv6+wepu+TxfJ7K6eFf335Z0GdkYY0uabNLp78g1wOHAHOAZsssz3eojDF5LaPtnOdh5qMzvZ6eSwhbg4Jr5WWlZw20k7QHsCzzfluhqKBvw71vAkoi4rX59RLwQETvS9F3AZGV3b7dVvDacyFay8anm1m1S5DNvl98BfhwRz9Wv6JbPM3lu4BJb+ru1wTZd8blK+gPgd4H56QTxBgW+Iy0VEc9FxK7IRkC4tsn7d/zzTOeb/wjc0mybdn+WTc5DLfl+diop3AccKenQ9KvxPKD+ATzLgIGW8g8C32v2ZW+VdF3x68DDEfFXTbY5YKCtQ9Jcss+0rclL0l6S9hmYJmt4rB9pdhnwMWXeBfyypurZbk1/hXXD51mj9jt4PvDtBtt8Bzhd2ZAu08k++++0KT4g660DXAKcFREvNdmmyHekperasP5Dk/cvcm5otQ8Aj0TE041WtvuzHOQ81JrvZztaz5u0qJ9J1oq+EbgsLbuS7IsNMJXs8sIGYDVwWAdi/C2yKtn9wNr0OhNYSDaUB8CFwHqyXhL3Au/pQJyHpfdfl2IZ+Dxr4xTwlfR5PwBUOvTvvhfZSX7fmmUd/zzJktQzwCtk113/M1kb1v8DHgfuBvZP21aAv6sp+4n0Pd0AfLwDcW4gu2488B0d6LV3IHDXYN+RNsf5f9J3736yE9rM+jjT/BvODe2KMS2/YeD7WLNtJz/LZuehlnw/PcyFmZnl3NBsZmY5JwUzM8s5KZiZWc5JwczMck4KZmaWc1IwM7Ock4KZmeX+P+DJpn0orpWVAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xad834d30>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "from time import sleep\n",
    "import numpy as np\n",
    "\n",
    "numberOfSamples = 20\n",
    "delayInSeconds = 1\n",
    "temperature = np.zeros(numberOfSamples)\n",
    "\n",
    "for i in range(numberOfSamples):\n",
    "    temperature[i]=temp_sensor.get_temperature()\n",
    "    sleep(delayInSeconds)\n",
    "\n",
    "for i in range(20):\n",
    "    print('temperature: {:.2f}'.format(temperature[i]))\n",
    "    \n",
    "plt.plot(range(numberOfSamples), temperature, 'ro')\n",
    "plt.title('Grove Temperature')\n",
    "plt.axis([0, int(len(temperature)), min(temperature)-1, max(temperature)+1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Copyright (C) 2021 Xilinx, Inc\n",
    "\n",
    "SPDX-License-Identifier: BSD-3-Clause"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "----"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "----"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
